﻿<xsl:stylesheet version="1.0"
	xmlns:date="http://exslt.org/dates-and-times"
  xmlns:ebe="http://cks/ebemethods"
	xmlns:string="http://exslt.org/strings"
	xmlns:ms="urn:schemas-microsoft-com:xslt"
  xmlns:dt="urn:schemas-microsoft-com:datatypes"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  exclude-result-prefixes="date ebe string">
  <xsl:param name="IsBlogOwner" />
  <xsl:param name="RelativeUrl" />
  <xsl:param name="Language" />
  <xsl:param name="FullDateTimePattern" />
  <xsl:param name="ShortTimePattern" />
  <xsl:param name="IsTechnoratiEnabled" />

  <xsl:output omit-xml-declaration="yes" />

<xsl:template match="/">

	<xsl:apply-templates select="rows/row"/>

</xsl:template>

<xsl:template match="row">

	<div class="blogPostContainer">
		<div class="blogListTitle">
			<h2><xsl:value-of select="Title"/>
        &#160;<xsl:value-of select="ebe:ExportPDF('themes/RoundedGreen/images/exportPDF.gif', ID)" disable-output-escaping="yes" />
      </h2>
		</div>
		
		<div class="blogText">
			<xsl:value-of select="Body" disable-output-escaping="yes" />
		</div>

		<div class="blogDetails">
      <xsl:value-of select="ebe:res('PostedBy')"/>&#160; 
			<span class="blogAuthor">
				<xsl:value-of select="substring-after(Author,'#')"/>&#160;
			</span>
      <xsl:value-of select="ebe:res('PostedOn')"/>&#160; 
			<span class="blogArticleDate">
				<xsl:variable name="publishedDate" select="date:parseDate(PublishedDate, 'yyyy-MM-dd HH:mm:ss')"/>
        <xsl:value-of select="ms:format-date($publishedDate, $FullDateTimePattern, $Language)"/> - <xsl:value-of select="ms:format-time($publishedDate, $ShortTimePattern, $Language)"/>&#160;
			</span>

			<span class="blogArticleCommentCount small">
        <xsl:value-of select="NumComments"/>&#160;
        <xsl:choose>
          <xsl:when test="NumComments = 1">
            <xsl:value-of select="ebe:res('Comment')"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="ebe:res('Comments')"/>
          </xsl:otherwise>
        </xsl:choose>
      </span>

			<div>
        <xsl:value-of select="ebe:res('Tags')"/>:
        <xsl:for-each select="string:split(CategoriesAsText, ';')">
          <a href="{ebe:createTagUrl(.)}">
            <xsl:value-of select="."/>
          </a>
          <xsl:if test="position() != last()">, </xsl:if>
        </xsl:for-each>
        
				<xsl:value-of select="substring-after(PostCategory,'#')"/>
        <xsl:if test="$IsTechnoratiEnabled = 'True'">
          <br/>
          <xsl:value-of select="ebe:res('TechnoratiTags')"/>:
          <xsl:for-each select="string:split(CategoriesAsText, ';')">
            <a href="http://technorati.com/tag/{.}" rel="tag">
              <xsl:value-of select="."/>
            </a>
            <xsl:if test="position() != last()">, </xsl:if>
          </xsl:for-each>
        </xsl:if>

      </div>
		</div>

		<xsl:if test="$IsBlogOwner = 'True'">
			<div class="blogCommands small">
				<a>
					<xsl:attribute name="href">
						/<xsl:value-of select="substring-after(FileDirRef,'#')"/>/EditPost.aspx?ID=<xsl:value-of select="ID"/>
					</xsl:attribute>
					[<xsl:value-of select="ebe:res('EditPost')"/>]
				</a>
			</div>
		</xsl:if>
	</div>

</xsl:template>

<xsl:template name="strip-tags"> 
	<xsl:param name="text"/> 
	<xsl:choose> 
	    <xsl:when test="contains($text, '&lt;')"> 
	            <xsl:value-of select="substring-before($text, '&lt;')"/> 
	            <xsl:call-template name="strip-tags"> 
	                    <xsl:with-param name="text" select="substring-after($text, '&gt;')"/> 
	            </xsl:call-template> 
	    </xsl:when> 
	    <xsl:otherwise> 
	            <xsl:value-of select="$text"/> 
	    </xsl:otherwise> 
	</xsl:choose> 
</xsl:template> 
  
</xsl:stylesheet>
